//index.js
//获取应用实例
const app = getApp()



Page({
  data: {
     loadTimes:0,
     isLoadOver:false,
     res:{
         list:[
            {
              id: "cke84o07fov9w0789wpub36wl",
              name: "CP_KG",
              updatedAt: "2020-08-24T06:16:57.421Z",
              createdAt: "2020-08-24T06:16:42.506Z",
              createUser: "li",
              code: "F000163",
              status: "A",
            },
            {
              id: "cke84o07fov9w078233wpub36wl",
              name: "CP_KN",
              updatedAt: "2020-08-22T06:16:57.421Z",
              createdAt: "2020-08-21T06:16:42.506Z",
              createUser: "quantianchao",
              code: "F000153",
              status: "B",
            },
            {
              id: "cke84o07fo229w078233wpub36wl",
              name: "CP_WEWE_WEWE",
              updatedAt: "2020-08-02T06:16:57.421Z",
              createdAt: "2020-08-05T06:16:42.506Z",
              createUser: "尚浩",
              code: "F000158",
              status: "C",
            },
            {
              id: "cke84o07fov9w0789wpub36wl",
              name: "CP_KG",
              updatedAt: "2020-08-24T06:16:57.421Z",
              createdAt: "2020-08-24T06:16:42.506Z",
              createUser: "li",
              code: "F000163",
              status: "A",
            },
            {
              id: "cke84o07fov9w078233wpub36wl",
              name: "CP_KN",
              updatedAt: "2020-08-22T06:16:57.421Z",
              createdAt: "2020-08-21T06:16:42.506Z",
              createUser: "quantianchao",
              code: "F000153",
              status: "B",
            },
            {
              id: "cke84o07fo229w078233wpub36wl",
              name: "CP_WEWE_WEWE",
              updatedAt: "2020-08-02T06:16:57.421Z",
              createdAt: "2020-08-05T06:16:42.506Z",
              createUser: "尚浩",
              code: "F000158",
              status: "C",
            }
         ],
         total:{
           count:34,
           hasNextPage: false
         }
     }
  },
  onLoad: function () {
    wx.setNavigationBarTitle({
      title: '处方列表'
    })
    wx.hideHomeButton();
  },

  
  onPullDownRefresh(){
     this.onLoad();
  },

  onReachBottom(){
     if(this.data.loadTimes > 3) {
        this.setData({
          isLoadOver:true
        })
        return;
     };
     wx.showLoading({
       title: '加载中...',
     })
     let addData =[
      {
        id: "22cke84o07fov9w0789wpub36wl",
        name: "CP_KG",
        updatedAt: "2020-08-24T06:16:57.421Z",
        createdAt: "2020-08-24T06:16:42.506Z",
        createUser: "li",
        code: "F000163",
        status: "A",
      },
      {
        id: "ck33e84o07fov9w078233wpub36wl",
        name: "CP_KN",
        updatedAt: "2020-08-22T06:16:57.421Z",
        createdAt: "2020-08-21T06:16:42.506Z",
        createUser: "quantianchao",
        code: "F000153",
        status: "B",
      },
      {
        id: "cke8554o07fo229w078233wpub36wl",
        name: "CP_WEWE_WEWE",
        updatedAt: "2020-08-02T06:16:57.421Z",
        createdAt: "2020-08-05T06:16:42.506Z",
        createUser: "尚浩",
        code: "F000158",
        status: "C",
      }
     ];
     let newData = this.data.res.list.concat(addData);
     this.setData({
       "res.list":newData
     })
     this.data.loadTimes++;
     setTimeout(()=>{
      wx.hideLoading({
        success: (res) => {},
      })
     },1500)
  },

  tapTableItem:function(){},

  searchInput(e){
      console.log(`input:%o`,e)
  },

  searchFocus(e){
    console.log(`focus:%o`,e)
  }
 


})